import os.path
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

path = os.path.join(os.path.abspath('html'),'frame.html')
driver = webdriver.Chrome()
driver.get(path)

f1 = driver.find_element(By.ID,'f1')
driver.switch_to.frame(f1)
inner_h3 = driver.find_element(By.ID,'inner_h3')
print(inner_h3.get_attribute('outerHTML'))

f2 = driver.find_element(By.ID,'f2')
driver.switch_to.frame(f2)
p1 = driver.find_element(By.ID,'p1')
print(p1.text)

# driver.switch_to.parent_frame()
# inner_h3 = driver.find_element(By.ID,'inner_h3')
# print(inner_h3.text)

# 切换到主页面
driver.switch_to.default_content()
h3 = driver.find_element(By.XPATH,'//h3')
print(h3.text)


time.sleep(2)
driver.quit()